#define  _CRT_SECURE_NO_WARNINGS
//struct HashTable {
//    struct ListNode* key;
//    UT_hash_handle hh;
//};
//
//struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB) {
//    struct HashTable* hashTable = NULL;
//    struct ListNode* temp = headA;
//    while (temp != NULL) {
//        struct HashTable* tmp;
//        HASH_FIND(hh, hashTable, &temp, sizeof(struct HashTable*), tmp);
//        if (tmp == NULL) {
//            tmp = malloc(sizeof(struct HashTable));
//            tmp->key = temp;
//            HASH_ADD(hh, hashTable, key, sizeof(struct HashTable*), tmp);
//        }
//        temp = temp->next;
//    }
//    temp = headB;
//    while (temp != NULL) {
//        struct HashTable* tmp;
//        HASH_FIND(hh, hashTable, &temp, sizeof(struct HashTable*), tmp);
//        if (tmp != NULL) {
//            return temp;
//        }
//        temp = temp->next;
//    }
//    return NULL;
//}


struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB) {
    if (headA == NULL || headB == NULL) {
        return NULL;
    }
    struct ListNode* pA = headA, * pB = headB;
    while (pA != pB) {
        pA = pA == NULL ? headB : pA->next;
        pB = pB == NULL ? headA : pB->next;
    }
    return pA;
}


